﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RptAllInOne.model;
using System.Data;
namespace RptAllInOne
{
    /// <summary>
    /// 主要业务类
    /// </summary>
    class RptDAL
    {
        /// <summary>
        /// 判断SQL语句是否正确
        /// </summary>
        /// <param name="commandText"></param>
        /// <returns></returns>
        public bool CheckSqlCorrect(string commandText)
        {
            string strsql = string.Empty;

            strsql = "SET NOEXEC ON {0} SET NOEXEC OFF";
            strsql = string.Format(strsql, commandText);
            

            return true;
        }
        /// <summary>
        /// 获取正确的SQL语句，将SQL中含有的关键字替换
        /// </summary>
        /// <param name="commmandtext"></param>
        /// <returns></returns>
        public string GetCorrectSql(string commmandtext)
        {
            string strsql;
            strsql = "";

            return strsql;
        }

        /// <summary>
        /// 浏览关键字
        /// </summary>
        public void ViewKeys()
        { 
        
        }
        /// <summary>
        /// 获取报表最大编号
        /// </summary>
        /// <returns></returns>
        public int GetMaxRptNo()
        {
            string strsql = "SELECT ISNULL(MAX(RPTNO),0) FROM INFO_RPT";

            return 1;
        }

        public bool SaveRpt(RptModel rm)
        {
            try
            { }
            catch
            { }

            return true;
        }

        public RptModel ReadTable(int _code)
        {
            string strsql = "SELECT * FROM INFO_RPT WHERE RPTNO='{0}'";


            return null;
        }
        /// <summary>
        /// 删除报表
        /// </summary>
        /// <param name="_code"></param>
        /// <returns></returns>
        public bool DeleteRpt(int _code)
        {

            return true;
        }
        /// <summary>
        /// 获取报表标题
        /// </summary>
        /// <param name="_code"></param>
        /// <returns></returns>
        public string GetRptCap(int _code)
        {
            return "";
        }

        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public DataSet SearchData(RptModel rm,bool isreplaceKey)
        {


            return null;

        }
        /// <summary>
        /// 替换SQL语句中的关键字
        /// </summary>
        /// <param name="commandtext"></param>
        /// <returns></returns>
        public string ReplaceKey(RptModel rm)
        {
            return rm.RptSql;
        }
    }
}
